﻿using System.Windows;

namespace SHomeWorkshop.LunarPresentation.Commands
{
    public partial class Command
    {
        public static void ArrowLocationSetup(Expressions.Arrow.ArrowLocation arrowLocation)
        {
            if (Globals.selectedEditor == null) return;
            if (Globals.selectedEditor.SelectedExpression == null) return;

            LunarPresentation.Expressions.Expression curEx
                = Globals.selectedEditor.SelectedExpression;

            Expressions.Arrow arrow = curEx as Expressions.Arrow;

            if (arrow == null)
            {
                MessageBox.Show("只有箭头式才支持“设置箭头位置”操作！", Globals.appName,
                    MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            if (arrow.Arrows == arrowLocation) return;//本就是这种。

            ModifingItem mi = new ModifingItem();
            Action action = new Action(arrow.ExID, -1, arrow.GetType().Name, "Arrows", arrow.Arrows.ToString(),
                arrowLocation.ToString());

            arrow.Arrows = arrowLocation;

            mi.Add(action);
            arrow.Editor.Do(mi);
        }
    }
}
